package practice;

import java.util.Random;

public class practice008 {
	// 随机生成比例1:3:5:7....
	public static void main(String[] args) {
		Random random = new Random(1);
		int seed = 100;

		int i, j, k, count = 0, m = 1, c = 1;
		int p, q, d;
		int[] a = new int[100];
		int[] f = new int[100000];
		for (int l = 0; l < a.length; l++) {
			a[l] = 0;
		}
		for (int l = 0; l < f.length; l++) {
			f[l] = 0;
		}

		int ct1, ct2, ct3, ct4, ct5, ct6, ct7, ct8, ct9, ct10;
		ct1 = ct2 = ct3 = ct4 = ct5 = ct6 = ct7 = ct8 = ct9 = ct10 = 0;
		// a[0]=1; a[1-3]=2; a[4-8]=3; a[9-15]=4
		// a*2-1;
		// i=1; i=3; i=5; i=7;
		int n = 100;
		int b = 100000;
		for (i = 0; i < n; i++)// 生成1-10的1:3:5..:19总个数100
		{
			// i 0 1-3 4-8 9-15
			// m 1 3 5 7

			// for(k=1;k<=m;k++){
			if (m == count) {
				c++;
				m = c * 2 - 1;// 对应的比例值1-3-5-...-19
				a[i] = m;
				System.out.println(a[i]);
				count = 0;
			} else {
				a[i] = m;
				System.out.println(a[i]);
			}
			count++;
			// }
		}

		System.out.println("\n\n");
		for (j = 0; j < 1000; j++) {
			p = random.nextInt(seed) % 100;
			q = random.nextInt(seed) % 100;
			if (p != q) {
				d = a[p];
				a[p] = a[q];
				a[q] = d;
			}
		}
		for (i = 0; i < n; i++)
			System.out.println(a[i]);

		System.out.println("\n\n");
		for (k = 0; k < b; k++) {
			d = random.nextInt(seed) % 100;
			f[k] = a[d];
			switch (f[k]) {
			case 1:
				ct1++;
				break;
			case 3:
				ct2++;
				break;
			case 5:
				ct3++;
				break;
			case 7:
				ct4++;
				break;
			case 9:
				ct5++;
				break;
			case 11:
				ct6++;
				break;
			case 13:
				ct7++;
				break;
			case 15:
				ct8++;
				break;
			case 17:
				ct9++;
				break;
			case 19:
				ct10++;
				break;
			}
		}
		System.out.println(ct1 + ":" + ct2 + ":" + ct3 + ":" + ct4 + ":" + ct5 + ":" + ct6 + ":" + ct7 + ":" + ct8 + ":"
				+ ct9 + ":" + ct10);

	}

}
